package com.animations;

import com.beans.WriterBean;
import creator.ui.graphics.Magicanvas;
import creator.ui.graphics.polaroid.Animation;
import java.awt.Graphics;
import java.util.ArrayList;

public class InitAction extends Animation {

  private WriterBean writer;
  private int writerX;

  public void loadBean() {
    this.writer = new WriterBean();
    getBeans().add(this.writer);
  }

  public void loadBeanpParameters() {
    this.writerX = this.writer.getWriterX();
  }

  public void paint(Graphics g) {
    g.drawImage(
      this.writer.getWriter(),
      this.writerX,
      this.writer.getWriterY(),
      this.writer.getWriterW(),
      this.writer.getWriterH(),
      getMagicanvas()
    );
  }

  public void run() {
    try {
      loadBeanpParameters();
      float drt = 1.0F;
      Thread.sleep(1200L);
      while (this.writerX >= 1 - this.writer.getWriterW()) {
        this.writerX = (int) (this.writerX - (drt += 0.5F));
        Thread.sleep(8L);
        getMagicanvas().repaint();
      }
      Thread.sleep(800L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
